<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
      Vue2 生命周期钩子在卸载阶段有一些不同，Vue2中叫销毁阶段
        1. beforeDestroy      销毁之前
        2. destroyed          销毁完成

      Vue2 组件实例上有一个 $destroy 方法，来销毁组件


     -->

    <div id="app">
      <button>{{ count }}</button>
      <button @click="$destroy()">销毁</button>
    </div>

    <script src="../lib/vue-2.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          count: 1,
        },
        beforeDestroy() {
          console.log("beforeDestroy");
        },
        destroyed() {
          console.log("destroyed");
        },
      });
    </script>
  </body>
</html>
